package com.honghu.cloud.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.google.common.collect.Maps;
import com.honghu.cloud.bean.GoodsSpecification;
import com.honghu.cloud.dao.GoodsSpecificationDao;
import com.honghu.cloud.common.service.BaseService;
import com.honghu.cloud.service.IGoodsSpecificationService;
import com.honghu.cloud.common.page.Page;

/**
 * 商品规格serviceImpl
 * @author Administrator
 *
 */
@Service
@Transactional(readOnly = true)
public class GoodsSpecificationServiceImpl extends BaseService<GoodsSpecification> implements IGoodsSpecificationService{

	@Autowired
	private GoodsSpecificationDao goodsSpecificationDao;

	@Transactional(readOnly = false)
	public void batchDelObjs(List<GoodsSpecification> objs) {
		if (objs != null && objs.size() > 0) {
			goodsSpecificationDao.batchDelete(objs);
		}
	}


	public GoodsSpecification getObjByProperty(String key, String operation_symbol, Object value) {
		Map<String, Object> maps = Maps.newHashMap();
		maps.put("operation_property", key);
		maps.put("operation_symbol", operation_symbol);
		maps.put("operation_value", value);
		List<GoodsSpecification> objs = goodsSpecificationDao.selectObjByProperty(maps);
		if (objs != null && objs.size() > 0) {
			return objs.get(0);
		}
		return null;
	}


	public List<GoodsSpecification> selectObjByProperty(Map<String, Object> maps) {
		return goodsSpecificationDao.selectObjByProperty(maps);
	}


	public List<GoodsSpecification> queryPages(Map<String, Object> params) {
		return goodsSpecificationDao.queryPages(params);
	}


	public List<GoodsSpecification> queryPageListWithNoRelations(Map<String, Object> param) {
		return goodsSpecificationDao.queryPageListWithNoRelations(param);
	}


	public List<GoodsSpecification> queryPagesWithNoRelations(Map<String, Object> params, Integer currentPage,
			Integer pageSize) {
		return goodsSpecificationDao.queryPagesWithNoRelations(params);
	}


	public Page<GoodsSpecification> queryPagesWithNoRelations(Map<String, Object> params) {
		return super.queryPagesWithNoRelations(params);
	}


	public Page<GoodsSpecification> list(Map<String, Object> params) {
		return super.list(params);
	}


	@Transactional(readOnly = false)
	public void batchDeleteByIds(List<Long> ids) {
		goodsSpecificationDao.batchDeleteByIds(ids);
	}


	@Transactional(readOnly = false)
	public void saveEntity(GoodsSpecification obj) {
		goodsSpecificationDao.saveEntity(obj);
	}


	@Transactional(readOnly = false)
	public void updateById(GoodsSpecification obj) {
		goodsSpecificationDao.updateById(obj);
	}


	@Transactional(readOnly = false)
	public void deleteById(Long id) {
		goodsSpecificationDao.deleteById(id);
	}


	public GoodsSpecification selectByPrimaryKey(Long id) {
		return goodsSpecificationDao.selectByPrimaryKey(id);
	}


	public List<GoodsSpecification> queryPageList(Map<String, Object> params, Integer begin, Integer max) {
		return super.queryPageList(params, begin, max);
	}


	public List<GoodsSpecification> queryPageList(Map<String, Object> params) {
		return this.queryPageList(params, null, null);
	}


	public int selectCount(Map<String, Object> params) {
		Integer c = goodsSpecificationDao.selectCount(params);
		if (c == null) {
			return 0;
		}
		return c;
	}


	@Transactional(readOnly = false)
	public boolean save(GoodsSpecification goodsSpecification) {
		int ret = goodsSpecificationDao.save(goodsSpecification);
		if (ret == 1) {
			return true;
		}
		return false;
	}


	@Transactional(readOnly = false)
	public void update(GoodsSpecification goodsSpecification) {
		goodsSpecificationDao.update(goodsSpecification);
	}


	@Transactional(readOnly = false)
	public void delete(Long id) {
		goodsSpecificationDao.delete(id);
	}
	
	@Transactional(readOnly = false)

	public void saveGoodsSpecificationGoodsClassDetail(List<Map<String, Object>> gspgcIds) {
		if(gspgcIds!=null && gspgcIds.size()>0){
			goodsSpecificationDao.saveGoodsSpecificationGoodsClassDetail(gspgcIds);
		}
	}
	
	@Transactional(readOnly = false)

	public void deleteGoodsSpecificationGoodsClassDetail(List<Map<String, Object>> gsgcds) {
		if(gsgcds!=null && gsgcds.size()>0){
			goodsSpecificationDao.deleteGoodsSpecificationGoodsClassDetail(gsgcds);
		}
	}


	@Override
	public List<GoodsSpecification> getGoodsIdSpecification(Long goods_id) {
		return goodsSpecificationDao.getGoodsIdSpecification(goods_id);
	}




}
